package controllers;

import org.springframework.util.StringUtils;

import play.mvc.*;
import play.mvc.Http.*;

import models.*;

public class Secured extends Security.Authenticator {
    
    @Override
    public String getUsername(Context ctx) {
    	String user = ctx.session().get("name");
        return  StringUtils.isEmpty(user) ? null : user;
    }
    
    @Override
    public Result onUnauthorized(Context ctx) {
        return redirect(routes.Application.login());
    }
    
}